package com.xgame.server.netty.service;

import com.xgame.server.netty.enity.MsgEntity;
import com.xgame.server.netty.handler.CmdHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

@Component
public class CmdMessageService implements MessageService {

    @Autowired
    private CmdHandler cmdHandler;

    @Override
    public void handleMsg(MsgEntity msgEntity) {
        List<MsgEntity> commandList = new ArrayList<MsgEntity>();// 用于存放处理后同时发送的几条消息
        try {
            cmdHandler.handleMsg(msgEntity, commandList);// 处理消息
        } catch (Exception e) {
            e.printStackTrace();
        }

        commandList.clear();
        commandList = null;
    }
}
